#!/usr/bin/env ruby

require 'set'

ip="128.8.126.92"
file=ARGV[0]
#file="data/rtt_trace.full.dat"

f = File.open(file, "r")

# map unacked sequence numbers to timestamps
seqs = Set.new
acks = Set.new

dup_seqs = 0;
dup_acks = 0;

f.each_line do |line|
    timestamp,ip_id, s_ip, d_ip, s_port, d_port, seq, ack, win_sz, tot_sz, data_sz   = line.split
    if(s_ip == ip) # The sender is the server.
        if(seqs.include?(seq)) # this is a duplicate
            dup_seqs += 1;
        else
            seqs.add(seq)
        end
    end
    if(d_ip == ip) # Receiver is the server. Got an ack
        if(acks.include?(ack))
            dup_acks += 1;
        else
            acks.add(ack)
        end
    end
end

puts dup_seqs, dup_acks, seqs.size, acks.size
